"""5.	编写一个函数，接受一个字典作为参数，字典的键是商品名称，值是商品价格。函数返回价格最高的商品名称。
test_cases = [
    {"苹果": 5, "香蕉": 10, "橙子": 8},
    {"A": 20, "B": 20, "C": 15},  # 多个最高价，返回多个
    {"手机": 999},
    {},
    {"书": -10, "笔": -5},  # 负价格，返回None
]

"""


def max_price(dic):
    if not dic :
        return []

    max_price = 0
    list1 = []
    for k, v in dic.items():
        if v > max_price:
            list1.clear()
            list1.append(k)
            max_price = v

        elif v == max_price:
            max_price = v
            list1.append(k)
    if not list1:
        return None

    return list1


test_cases = [
    {"苹果": 5, "香蕉": 10, "橙子": 8},
    {"A": 20, "B": 20, "C": 15},  # 多个最高价，返回多个
    {"手机": 999},
    {},
    {"书": -10, "笔": -5},  # 负价格，返回None
]

for dic in test_cases:
    print(max_price(dic))





# def max_price(dic):
#     max_price = 0
#     max_name = None
#     for k, v in dic.items():
#         if v > max_price:
#             max_price = v
#             max_name = k
#     return max_name
# test_cases = [
#     {"苹果": 5, "香蕉": 10, "橙子": 8},
#     {"A": 20, "B": 20, "C": 15},  # 多个最高价，返回多个
#     {"手机": 999},
#     {},
#     {"书": -10, "笔": -5},  # 负价格，返回None
# ]
# for dic in test_cases:
#     print(max_price(dic))
